package ar.edu.utn.frba.tacs.grupo04.CarpielaCarpeta.Persistencia;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.classic.Session;

public class Sesion {

	public void iniciarSesion(Object unObjeto) throws Exception {
		AnnotationConfiguration configuration = new AnnotationConfiguration();
		// configuration.addAnnotatedClass(unObjeto.class);
		SessionFactory sessionFactory = configuration.configure()
				.buildSessionFactory();
		Session session = sessionFactory.getCurrentSession();

		session.beginTransaction();
	}

	public void persistir(Object unObjeto, SessionFactory sessionFactory) {

		Session session = sessionFactory.getCurrentSession();

		session.save(unObjeto);
		session.flush();
		session.getTransaction().commit();

	}

}